<template>
	<view>
		<navbar :parameter='parameter'></navbar>
		<view class="wap">
			<block v-for="(item,index) in orderList" :key='index' v-if="orderList.length > 0 ">
				<view class="order-item" @click="detail(item.id)">
					<view class="title-line acea-row row-between-wrapper">
						<view class="num">订单号：{{item.order_sn}}</view>
					</view>
					<view class="line acea-row row-between-wrapper">
						<view class="title">{{item.order_info.user_name}} <text style="margin-left: 20rpx;">{{item.order_info.user_sex}}</text> </view>
						<view class="price">￥{{item.pay_price}}</view>
					</view>
					<view class="type">{{item.product_name}}</view>
					<view class="time">下单时间：{{item.createtime}} </view>
				</view>
			</block>
			<u-empty mode="order" icon="http://cdn.uviewui.com/uview/empty/order.png" v-if="orderList.length == 0 ">
			</u-empty>
		</view>
		<u-loadmore :status="status" line dashed @loadmore="loadmore" v-if="orderList.length > 0" />
		<u-toast ref="uToast"></u-toast>
		
	</view>
</template>

<script>
	let app = getApp();
	export default {
		data() {
			return {
				parameter: {
					'navbar': '1',
					'return': '1',
					'title': '我的订单',
					'color': true,
					'class': 'on'
				},
				id:'',
				orderList: [],
				status: 'loadmore',
				limit: 10,
				page: 1,
				total_num: '',
			}
		},
		onLoad(option) {
			this.id = option.id;
			this.orderList = [];
			this.page = 1;
			this.orderLists();
		},
		onShow() {

		},
		onReachBottom() {
			this.loadmore()
		},
		methods: {
			async orderLists() {
				const res = await this.$myRequest({
					url: '/api/wxfw/my_order', //把接口传过去
					data: {
						page: this.page,
						limit: this.limit,
						type: 11,
						openid: uni.getStorageSync('openid'),
						uid:this.id
					}
				})
				console.log(res.data)
				this.orderList = [...this.orderList, ...res.data.data];
				this.total_num = res.data.total_num;
			},
			
			loadmore() {
				console.log(11111)
				if (this.total_num == this.orderList.length) {
					this.status = 'nomore';
				} else {
					this.status = 'loading';
					this.page++;
					this.orderLists();
				}
				setTimeout(() => {
					if (this.total_num == this.orderList.length) this.status = 'nomore';
					else this.status = 'loading';
				}, 2000)
			},
			
			detail(id){
				uni.navigateTo({
					url:'/bundle/pages/birth/orderdetail?id='+id+'&active=1'
				})
			}
		}
	}
</script>

<style style="scss" scoped>
	page {
		background-color: #F4F4F4;
	}

	.wap {
		padding: 20rpx 30rpx;
	}

	.order-item {
		width: 100%;
		border-radius: 20rpx;
		background-color: #fff;
		margin-bottom: 30rpx;
		padding: 30rpx;
	}

	.order-item .title-line {
		padding-bottom: 20rpx;
		color: #666666;
		font-size: 26rpx;
		border-bottom: 1px solid #F4F4F4;
	}


	.order-item .title-line .num {
		width: 480rpx;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
		color: #595D68;
	}

	.order-item .title-line .status {
		color: #999999;
	}

	.order-item .title-line .status.orange {
		color: #FE8802;
	}

	.order-item .title-line .status.blue {
		color: #347DFE;
	}

	.order-item .line {
		color: #000;
		padding: 20rpx 0;
		font-size: 30rpx;
	}

	.order-item .line .number {
		color: #333333;
	}

	.order-item .type {
		color: #666;
		font-size: 26rpx;
		padding-bottom: 20rpx;
	}
	.order-item .time {
		color: #999;
		font-size: 24rpx;
	}
	.order-item .order-bottom {
		padding-top: 30rpx;
		font-size: 24rpx;
		color: #999999;
	}
	.order-item .order-bottom .price text {
		font-size: 36rpx;
		font-weight: 700;
	}
	.order-item .order-bottom .btn {
		border-radius: 30rpx;
		width: 150rpx;
		height: 54rpx;
		font-size: 26rpx;
		text-align: center;
		color: #000000;
		border: 1px solid #CBCBCB;
		margin-left: 20rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.order-item .order-bottom .btn.bg-blue {
		background-color: #347DFE;
		border: 1px solid #347DFE;
		color: #fff;
	}

</style>
